"""
消息相关 Schemas
"""
from pydantic import BaseModel, Field, ConfigDict
from typing import Optional, Dict, Any
from datetime import datetime


class MessageBase(BaseModel):
    """消息基础信息"""
    type: str = Field(..., pattern="^(booking|team|team_application|team_application_result|payment|system)$")
    title: str = Field(..., min_length=1, max_length=200)
    content: str = Field(..., min_length=1, max_length=1000)
    link: Optional[str] = None
    extraData: Optional[Dict[str, Any]] = None


class MessageCreate(MessageBase):
    """创建消息"""
    userId: str


class MessageResponse(MessageBase):
    """消息响应"""
    id: str
    isRead: bool = False
    createdAt: Optional[datetime] = None
    
    model_config = ConfigDict(
        from_attributes=True,
        populate_by_name=True
    )

